package org.begincode.admin.service;

import com.begincode.common.constant.Constant;
import org.begincode.core.mapper.CourseMapper;
import org.begincode.core.mapper.VideoChapterMapper;
import org.begincode.core.mapper.WordChapterMapper;
import org.begincode.core.model.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class ChapterService {
	private Logger logger = LoggerFactory.getLogger(ChapterService.class);

	@Resource
	private WordChapterMapper wordChapterMapper;
	@Resource
	private VideoChapterMapper videoChapterMapper;

	public int addWordChapter(WordChapter wordChapter){
		return wordChapterMapper.insertSelective(wordChapter);
	}

	public List<WordChapter> selWordChapter(){
		WordChapterExample wordChapterExample = new WordChapterExample();
		wordChapterExample.createCriteria().andDeleteFlagEqualTo(Constant.NO_DEL_FLAG);
		return wordChapterMapper.selectByExample(wordChapterExample);
	}

	public int addVideoChapter(VideoChapter videoChapter){
		return videoChapterMapper.insertSelective(videoChapter);
	}

	public List<VideoChapter> selVideoChapter(){
		VideoChapterExample videoChapterExample = new VideoChapterExample();
		videoChapterExample.createCriteria().andDeleteFlagEqualTo(Constant.NO_DEL_FLAG);
		return videoChapterMapper.selectByExample(videoChapterExample);
	}
}
